<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #ad{
            width: 200px;
            height: 200px;
            border:solid 1px #ddd;
        }
    </style>
</head>
<body>
    <div id="ad"></div>

    <script>
        'use strict';
        const ad = document.querySelector('#ad');

        // function test(){
        //     console.log(this);
        // }
        // //问 ad 元素点击时, this 指向谁
        // ad.onclick = test.bind(undefined);

        class App{
            render(){
                //绑定事件
                // ad.onclick = function(){
                //     console.log(this);
                // }

                ad.onclick = this.test.bind(undefined);  
                
            }

            test(){
                console.log(this);
            }
        }

        let app = new App();
        app.render();

    </script>
</body>
</html>